In [30]:
import numpy as np
import matplotlib.pylab as plt
In [31]:
#Define constants - current, permittivity of free space, permeability of free space, wire radius a, speed of light c.
I = 4
e_0 = 8.85 * 10**(-12)
u_0 = 1.26 * 10**(-6)
a = 0.005
c = 2.99792 * 10**8
In [32]:
#Define energy density as a function of position and time.
def u(s, t):
return (u_0 * I**2) / (8 * np.pi * a**4) * (4 * c**2 * t**2 + s**2)
In [62]:
#Plot energy density as a function of radius from wire axis.
fig = plt.figure(figsize = (8, 6))
ax = fig.add_subplot(1, 1, 1)
#Pretend to plot the function as a smooth curve by plotting a thousand points close together.
s = np.linspace(0, a, 1000)
#Above creates 1000 points at evenly-spaced locations between 0 and h. The function 'linspace' is in the package 'numpy'.
#Plot for t = 0.
ax.plot(s, u(s, 0.01), label = 'Energy Density')
#Label the plot.
ax.set_xlabel('Radius from Center of Wire (meters)', fontsize = 14)
ax.set_ylabel('Energy Density, $u$ ($\\frac{J}{m^{3}}$)', fontsize = 14)
ax.set_title('Energy Density in Narrow Gap \n at Different Distances from Axis', fontsize = 16)
#Adjust the axes.
#ax.axis([0, 0.006, 4.6e16, 4.63e16])
plt.show()
In [40]:
#Define energy in the whole gap as a function of time.
def U(t):
return (u_0 * I**2 * w) / (4 * np.pi * a**2) * (2 * c**2 * t**2 + 1/4 * a**2)
#Define the width of the gap. It is "much smaller than a". At this point, I am guessing about the magnitude appropriate for this approximation.
w = a/100
In [46]:
#Plot energy as a function of time.
fig = plt.figure(figsize = (8, 6))
ax = fig.add_subplot(1, 1, 1)
#Pretend to plot the function as a smooth curve by plotting a thousand points close together.
t = np.linspace(0, a, 1000)
#Above creates 1000 points at evenly-spaced locations between 0 and h. The function 'linspace' is in the package 'numpy'.
#Plot for t = 0.
ax.plot(s, U(t), label = 'Energy')
#Label the plot.
ax.set_xlabel('Time from Beginning of Current Flow (s)', fontsize = 14)
ax.set_ylabel('Energy, $U$ ($J$)', fontsize = 14)
ax.set_title('Energy in Narrow Gap \n at Different Distances from Axis', fontsize = 16)
#Adjust the axes.
#ax.axis([0, 0.006, 4.6139e20, 4.6140e20])
plt.show()
In [49]:
#Define power in the whole gap as a function of time.
def P(t):
return (- u_0 * I**2 * w) / (np.pi * a**2) * (c**2 * t)
#Define the width of the gap. It is "much smaller than a". At this point, I am guessing about the magnitude appropriate for this approximation.
w = a/100
In [60]:
#Plot power as a function of time.
fig = plt.figure(figsize = (8, 6))
ax = fig.add_subplot(1, 1, 1)
#Pretend to plot the function as a smooth curve by plotting a thousand points close together.
t = np.linspace(0, a, 1000)
#Above creates 1000 points at evenly-spaced locations between 0 and h. The function 'linspace' is in the package 'numpy'.
#Plot for t = 0.
ax.plot(s, P(t), label = 'Power')
#Label the plot.
ax.set_xlabel('Time from Beginning of Current Flow (s)', fontsize = 14)
ax.set_ylabel('Power, $P$ ($\\frac{J}{m^{2}}$)', fontsize = 14)
ax.set_title('Power Flowing into Narrow Gap \n at Different Distances from Axis', fontsize = 16)
#Adjust the axes.
#ax.axis([0, 0.006, 4.6139e20, 4.6140e20])
plt.show()
In [61]:
#Plot power as a function of time.
fig = plt.figure(figsize = (8, 6))
ax = fig.add_subplot(1, 1, 1)
#Pretend to plot the function as a smooth curve by plotting a thousand points close together.
t = np.linspace(0, a, 1000)
#Above creates 1000 points at evenly-spaced locations between 0 and h. The function 'linspace' is in the package 'numpy'.
#Plot for t = 0.
ax.plot(s, -P(t), label = 'Power')
#Label the plot.
ax.set_xlabel('Time from Beginning of Current Flow (s)', fontsize = 14)
ax.set_ylabel('Power, $P$ ($\\frac{J}{m^{2}}$)', fontsize = 14)
ax.set_title('Power Flowing Out of Narrow Gap \n at Different Distances from Axis', fontsize = 16)
#Adjust the axes.
#ax.axis([0, 0.006, 4.6139e20, 4.6140e20])
plt.show()